package com.lmx.repoDomain.tmodel;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiLookupIncludeAutomatically;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 随时任务标签
 *
 * @author ytche
 * @date 2017年9月9日
 *
 */
@JsonApiResource(type = "nursingServiceItemSign")
@Entity
@Table(name = "tnb_nursing_service_item_sign")
public class NursingServiceItemSign extends BaseEntity {
	private static final long serialVersionUID = 1L;
	private String name;
	private String remark;
	private NursingProjectServiceItem item;
	private Set<NursingPlanExecute> exes;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "service_item_id")
	public NursingProjectServiceItem getItem() {
		return item;
	}

	public void setItem(NursingProjectServiceItem item) {
		this.item = item;
	}

	@JsonIgnore
	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH, mappedBy = "signs")
	@Fetch(FetchMode.SELECT)
	@JsonApiToMany
	@JsonApiLookupIncludeAutomatically
	public Set<NursingPlanExecute> getExes() {
		return exes;
	}

	public void setExes(Set<NursingPlanExecute> exes) {
		this.exes = exes;
	}
}
